<%@ page contentType="text/html;charset=utf-8" language="java"
	pageEncoding="UTF-8" import="java.util.Date"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<%@include file="../../common/mastertopedit.jsp"%>
<input type="hidden" id="channelId" value="${model.channelId}">
<div class="form-horizontal pt-15  form-clean-magin">
	<div class="form-group">
		<label for="inputEmail3"
			class="col-xs-3 text-right control-label usual-label">渠道编码</label>
		<div class="col-xs-9">
			<input class="form-control form-control-260 pull-left" type="text"
				name="channelCode" id="channelCode" maxlength="100" type="text"
				pattern="/[^a-zA-Z\d]+/"
				<c:if test="${model.channelInfo.id!=null}">disabled="disabled"</c:if>
				value="${model.channelInfo.channelCode}"> <i
				class="plum-sign-right">*</i>
		</div>
	</div>

	<div class="form-group">
		<label for="inputEmail3"
			class="col-xs-3 text-right control-label usual-label">渠道名称</label>
		<div class="col-xs-9">
			<input class="form-control form-control-260 pull-left" type="text"
				name="channelName" id="channelName" maxlength="100" type="text"
				value="${model.channelInfo.channelName}"> <i
				class="plum-sign-right">*</i>
		</div>
	</div>

	<div class="form-group">
		<label for="inputEmail3"
			class="col-xs-3 text-right control-label usual-label">备注</label>
		<div class="col-xs-9">
			<input class="form-control form-control-260 pull-left" type="text"
				name="remark" id="remark" maxlength="100" type="text"
				value="${model.channelInfo.remark}">
		</div>
	</div>
</div>

<div class="form-group text-center">
	<button type="button" class="runmi-btn runmi-primary"
		onclick="backIndex()">取消</button>
	<button type="button" class="runmi-btn runmi-sure-btn" onclick="save()">保存</button>
</div>
<script type="text/javascript">
	function save() {
		var channelId = $('#channelId').val();
		var postData = "channelId=" + channelId;

		var channelCode = $('#channelCode').val();
		if (channelCode == '' && channelId == '') {
			layer.alert('请输入渠道编码');
			return;
		}
		postData = postData + "&channelCode=" + encodeURIComponent(channelCode);

		var channelName = $('#channelName').val();
		if (channelName == '') {
			layer.alert('请输入渠道名称');
			return;
		}
		postData = postData + "&channelName=" + encodeURIComponent(channelName);

		var remark = $('#remark').val();
		postData = postData + "&remark=" + encodeURIComponent(remark);

		var url = "updateChannel";
		if (channelId == '') {
			url = "saveChannel";
		}

		layer.load(1, {
			shade : [ 0.5, '#fff' ]
		});
		//alert(url + postData);
		$.ajax({
			type : "POST",
			url : url,
			data : postData,
			contentType : "application/x-www-form-urlencoded;charset=UTF-8",
			async : true, // 同步  true 异步。默认是异步
			dataType : 'json',
			error : function(resultdata) {
				layer.closeAll();
			},
			success : function(resultdata) {
				layer.closeAll();
				if (resultdata.returnCode == "0000") {
					layer.alert('操作成功', {
						icon : 1
					}, function() {
						parent.editReturn();
					});
				} else {
					layer.alert(resultdata.returnMessage);
				}
			}
		});
	}
	function backIndex() {
		parent.editReturn();
	}
</script>
<%@include file="../../common/masterbottom.jsp"%>
